package com.shop.cereshop.app.tencent.im.delay.init;

import com.shop.cereshop.app.tencent.im.delay.constant.BusinessType;
import com.shop.cereshop.app.tencent.im.delay.handler.RedPacketTaskHandler;
import com.shop.cereshop.app.tencent.im.delay.handler.TransferOrderTaskHandler;
import com.shop.cereshop.app.tencent.im.delay.service.RDelayedQueueService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @description: 队列初始化器，在应用启动时初始化不同业务类型的队列
 * @author zdd
 * @date 2025/9/24 15:25
 * @version 1.0
 */
@Component
public class DelayQueueInitializer {

    @Resource
    private RDelayedQueueService delayedQueueService;
    @Resource
    private RedPacketTaskHandler redPacketTaskHandler;
    @Resource
    private TransferOrderTaskHandler transferOrderTaskHandler;

    @PostConstruct
    public void init() {
        // 初始化红包过期退款队列
        delayedQueueService.initQueue(BusinessType.RED_PACKET_EXPIRE_REFUND);
        delayedQueueService.registerHandler(redPacketTaskHandler);

        // 初始化转账订单过期退款队列
        delayedQueueService.initQueue(BusinessType.TRANSFER_ORDER_EXPIRE_REFUND);
        delayedQueueService.registerHandler(transferOrderTaskHandler);
    }

}
